package com.example.service;

import com.example.dao.MenuDao;
import com.example.dao.impl.MenuDaoImpl;
import com.example.entity.IndexInfo;
import com.example.utils.InitResult;
import com.example.utils.ResultData;
import lombok.Data;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
@Data
@Service
public class MenuService {
    MenuDao menuDao=new MenuDaoImpl();
    public InitResult getMenusAll(int id) {
        InitResult initResult=new InitResult();
        initResult.setHomeInfo(new IndexInfo("首页","page/welcome-1.html?t=1"));
        initResult.setLogoInfo(new IndexInfo("LAYUI MINI","images/logo.png",""));
        List<IndexInfo> indexInfoList=new ArrayList<>();
        IndexInfo indexInfo=new IndexInfo();
        indexInfo.setTitle("常规管理");
        indexInfo.setIcon("fa fa-address-book");
        indexInfo.setTarget("_self");
        List<IndexInfo> indexInfoList1 = menuDao.selectResByUserId(0,0);
        for (IndexInfo indexInfo1:indexInfoList1) {
            List<IndexInfo> indexInfoList2 = menuDao.selectResByUserId(1,indexInfo1.getId());
            indexInfo1.setChild(indexInfoList2);
        }
        indexInfo.setChild(indexInfoList1);
        indexInfoList.add(indexInfo);
        initResult.setMenuInfo(indexInfoList);
        return initResult;
    }
}
